<?php
$clave = $_GET['kd'];
$id_cliente = $_GET['nm'];
?>
<html>
    <?php include('include.header.html'); ?>
    <body class="bodycliente">
        <form id="frm_bp" name="frm_bp" method="post">
            
                <input type="hidden" id="id" name="id" value="<?php echo $id_cliente;?>">
				<input type="hidden" id="actual" name="actual" value="<?php echo $clave;?>">
        <div id="usuario" align="center">
            
            <table class="marco">
                <tr>
        <td height="10%">
         <?php include('menu_clientes.php'); ?>
        </td>
	    <tr>
		<td align="center">
                    <div id="DATO_HIDE" style="display:none" style="width:90%">
                    <div id="DATO" class="mensajes">&nbsp;</div>
                </div>
					<table class="formulario">
						<tr>
							<td>Ingrese la nueva clave</td>
							<td><input type="password" id="nueva" name="nueva" class="validate['required','length[6,10]']"></td>
						</tr>
						<tr>
							<td>Confirme la nueva clave</td>
							<td><input type="password" id="r_nueva" name="r_nueva" class="validate['confirm[nueva]']"></td>
						</tr>
						<tr>
							<td align="right">
							<input type="button" value="Cancelar">
							</td>
							<td align="left">
							<input type="submit" id="submit" name="submit" value="Guardar">
							</td>
						</tr>
					</table>
					</td>
                </tr>
                <tr>
			<td height="10%" valign="bottom" align="center">
			<?php include('footer.php'); ?>
			</td>
			</tr>
            </table>
            
        </div>
        </form>
    </body>
    <?php include('include.footer.html'); ?>
    <script>
    ///////////////////////////////
    var myCheck;
	myCheck = new FormCheck('frm_bp', {
	  submit:false,
		display:{
			errorsLocation : 1,
			indicateErrors : 2,
			keepFocusOnError : 0,
			closeTipsButton : 1,
			checkValueIfEmpty:1,                
			showErrors : 1
		}
	});		 
 
    $('frm_bp').addEvent('submit',function(ev){
        var IsValid;
       IsValid=myCheck.isFormValid();                                                                          
        if (IsValid){ 
            
             Ejecutor();
        }    
    });
    ///////////////////////////////

    function Ejecutor(){        
        window.addEvent('domready', function() {      	       
    		var req = new Request.JSON({
                method: 'POST',
                url: 'ajax/ajax_cambio_clave_clientes.php', 
                data: $('frm_bp'),                
                noCache:true,                     
                onRequest: function(){
                    $('submit').disabled = true;
                    $('DATO_HIDE').show();
//                    $('DATO').innerHTML = 'Procesando ...'; 
                },
                onComplete: function(){
                    setTimeout(function(){
                        $('DATO_HIDE').fade('out').get('tween').chain(function() {
                            $('DATO_HIDE').hide();
                            $('DATO_HIDE').fade('in');                                                         
                        });
                    },2000);                                                                                                                                                                                                              
                },             
                onSuccess: function(response){
                    switch(parseInt(response.RESULT)){
                        case 0:
                            $('DATO').innerHTML = "Operaci&oacute;n exitosa";  
                            window.location='cambio_clave_clientes_respuesta.php';
                            break;
                        case 1:
                            $('DATO').innerHTML = response.ERROR;
                            $('submit').disabled = false;
                            break;
                    }
                }
            }).post();        
       });
    }
    </script>
</html>
